home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
ps85a14.arc
/
LEVELI.DOC
< prev
next >
Wrap
Text File
|
1988-05-15
|
24KB
|
691 lines
PseudoSam Assembler Manual Level I
Copyright(c) 1986,87,88 PseudoCode
All right reserved!
Disclaimer:
PseudoSam software is distributed as is, with no guarantee that
it will work correctly in all situations. In no event will the
Author be liable for any damages, including lost profits,
lost savings or other incidental or consequential damages
arising out of the use of or inability to use these
programs, even if the Author has been advised of the
possibility of such damages, or for any claim by any other
party.
It is the users reponsibility to back up all important files!
See copyright information in appendix B
Table of Contents
Chapter 1 PseudoSam Assemblers vs. other assemblers.
Chapter 2 Running the assembler program.
Chapter 3 Assembler statement syntax.
Chapter 4 Data types.
Chapter 5 Expressions.
Chapter 6 Assembler Directives.
(also known as assembler pseudo-opcodes, or pseudo-ops)
Appendix A ASCII character set.
Appendix B Copyright information.
Chapter 1 PseudoSam assemblers vs. other assemblers
All PseudoSam(Pseudo brand Symbolic AsseMbler) assemblers conform to
a common syntax based on the UNIX system V assembler syntax. By
conforming to this Pseudo standard, conflicts with the manufacturers
syntax are created.
* The difference between another assembler's name and the PseudoSam name
of an assembler directive can be circumvented by the .opdef
directive.
example
.opdef eject,.eject ;defines eject to be synonymous with .eject
.opdef fcc,.db ;fcc will now form constant characters as it
;should.
* A file syn.asm is distributed with the assembler with some useful
redefinitions.
Unix system V is a trademark of AT & T.
Chapter 2 Running the assembler program
1. Command line switch setting and source file specification.
Assuming the user has an assembly language source file called foo.asm
type the following command:
aXX foo
where the PseudoSam assembler number is substituted for XX.
The assembler will assemble the program foo.asm using the default
assembler switch settings. the following files will be generated
by the assembler:
foo.lst ;assembled listing shown the code conversion and
; any errors that where discover by the assembler.
foo.obj ;assembled object code in Hex format.
** for a list of switch setting see the .command assembler directive
description in chapter 6.
*** The assembler uses the following temporary file names.
z0z0z0z0.tmp
z1z1z1z1.tmp
ANY files with these names will be DESTROYED by the
by the assembler.
Chapter 3 Assembler statement syntax
1. Assembler Statements
Assembler statements contain from zero to 4 fields as shown in
following.
<label> <opcode> <expressions> <comment>
All fields are optional, but they must be in this order.
A. Labels (<label>) are symbolic names that are assigned the starting
address of any code generated by the opcode and or expressions
of the line containing the label declaration.(see section 2).
B. Operation codes(<opcode>) tell the assembler what machine instruction
to generate, or what assembler control function to perform.
The operation code also tells the assembler what expressions are
required to complete the machine instruction or assembler directive.
(see chapter 6).
C. Expression requirements are set by the opcode(see the microprocessor
manufacturers reference manual or the assembler directives chapter
for individual opcode requirements).(see chapter 5).
D. Comments are notes written by the programmer to explain what the
program is trying to accomplish. Comments generate no code.
(see section 3).
2. Labels
Labels can be unlimited in length, but only the first eight characters
are used to distinguish between them. They must conform to the
following syntax.
<label> -> <identifier>':'
<identifier> -> <alphabetic character> <identifier character string>
<alphabetic character> -> character in the set ['A'..'Z', 'a'..'z', '.']
<identifier character string> -> any sequence of characters from the
set ['A'..'Z','a'..'z', '.', '0'..'9']
example
abc: ;label referred to as abc
a c: ;not a valid label
foo: ;label referred to as foo
.123: ;label referred to as .123
* Case makes NO difference!
d: ;is the same as
D:
3. Comments
Comments must start with a semi-colon ; and are terminated
by an end of line or file( <lf>(^J) or <sub>(^Z) ). An end
of line is inserted by typing the enter or return key by
most text editors.
Chapter 4 Data types
1. Integers
Integer constants can be specified in any of the following forms:
A. Binary
b'bb ;bb=string of binary digits
B'bb
B. Decimal
ndd
d'dd ;n=nozero decimal digit
D'dd ;dd=string of decimal digits
C. Octal
0qq ;qq=string of octal digits
o'qq
O'qq
q'qq
Q'qq
D. Hexidecimal
0x'hh ;hh=string of hexidecimal digits
0X'hh
h'hh
H'hh
x'hh
X'hh
Examples:
077 ;octal number 77 = decimal 63
b'0101 ;binary number 101 = decimal 5
77 ;decimal number 77 = octal 115
h'ff ;hexidecimal ff = decimal 255
2. Strings:
Strings consist of a beginning quote " followed by any reasonable number
of characters followed by an ending quote ". Control characters and double
quotes " and backslash \ may not be used in strings directly. These
special characters are included by using a special escape sequence which
the assembler translates into the appropriate ASCII code.
Note: Strings may not be used in expressions!
Although character constants may(see below).
Escape sequences
"\"" string containing "
"\\" string containing \
"\'" string containing '
"\0" string containing null
"\n" string containing linefeed
"\r" string containing carriage return
"\f" string containing formfeed
"\t" string containing horizontal tab
"\nnn" string containing the ASCII character who's code is o'nnn
(nnn are octal digits).
* see appendix A for ASCII codes.
3. Character Constants:
Character constants consist of a single quote ' followed by
a character or an escape sequence(see above) followed by a
single quote '.
example:
'A' = ASCII character value for the letter A = 65 (decimal);
'\''= ASCII character value for the character ' = 39 (decimal).
Character constants are treated as integers by the assembler and
are valid where ever an integer value is valid.
example:
'A' + 1 = 66
* see appendix A for ASCII codes.
4. Symbolic values
Symbolic values are generally labels, but may be any identifier
assigned an integer value(using .set or .equ pseudo-ops).
As a special case the symbol * when used as an operand in an
expression denotes the value of the location counter (the value
the program counter will have during operation) at the beginning
of the current line.
Chapter 5 Expressions
All expressions evaluate to integer values modulo 65536(2^16) and are
written in infix notation(the way you normally write them). Operators
provided are grouped below in order of precedence.
1. (unary)
~ logical bit wise complement(not) of its operand(one's complement).
- arithemetic complement, or negation(two's complement).
2. (binary)
* integer multiply (two's complement).
/ integer divide (two's complement).
% modulus (result is always positive)
>> logical shift right (left operand shifted right operand times).
<< logical shift left (left operand shifted right operand times).
~ equivalent to A or ( ~B ).
3. (binary)
| logical bitwise or(inclusive-or) of two operands.
^ logical bitwise exclusive-or of two operands.
& logical bitwise and of two operands.
4. (binary)
+ addition (two's complement).
- subtraction (two's complement).
Since this version does not generate relocatable code there exists only
one "type" of operand that can be in an expression. So anything goes
except divide by 0(1 will be substituted ).
examples:
-1 = h'ffff (two's complement notation).
-1 >> 8 = h'00ff
-1 << 8 = h'ff00
3 / 2 = 1
6 / 2 = 3
5 / 0 = 5
-2 / 1 = -2
-3 /-2 = 1
2 * -3 = -6
b'00 & b'11 = 0
b'11 & b'10 = 2
2 * b'01 & b'10 = 2
b'01 ^ b'11 = 2
b'01 | b'11 = 3
Notice that spaces are ignored in expressions.
Chapter 6 Assembler Directives
(also known as assembler Pseudo-opcodes)
The assembler recognizes the following directives:
directive section description
.command 1 ;set assembly options(similar to command line options).
.org 2 ;set program origin.
.equ 3 ;equate an identifier to an expression(permanent
; assignment).
.set 4 ;equate and identifier to an expression(temporary
; assignment).
.rs 5 ;reserve storage(memory) space.
.db 6 ;define byte.
.dw 7 ;define word(16 bit).
.drw 8 ;define reversed word(16 bit).
.eject 9 ;form feed in listing
.page 10 ;align location counter on 256 byte memory
; page boundary.
.end 11 ;end of program
.opdef 12 ;equate an identifier with another identifier.
.segment 13 ;define a memory segment.
<segment name>
14 ;select segment <segment name> as current segment.
.null 15 ;this is a comment statement.
1. .command <optionlist> ;allows the programmer to set option switches
;in the same manner as on the command line.
;(the command line is the line typed to run
; this program).
<optionlist> -> <option> ' ' <optionlist>
<optionlist> ->
<option> -> '-'<available option>
<option> -> '+'<available option>
<available option> -> 'a'<decimal number> ;Hex hode format.
;1 => Intel Hex.
;2 => Motorola 19 Hex.
<available option> -> 'w'<decimal number> ;page width in columns(characters).
;(-,+ are ignored but one must be
; there).
<available option> -> 'h'<decimal number> ;page height in lines.
;(-,+ are ignored but one must be
; there).
<available option> -> 'l' ;listing on(+) or off(-)
;if set on command line it overrides
;all listing controls in program.
<available option> -> 'm'<decimal number> ;Machine level.
;1 => 6800,2,8.
;2 => 6801,3.
<available option> -> 's' ;symbol listing on(+) or off(-).
<available option> -> 'o' ;selects single object module
;file only(+), or multiple object
;module files(-)(one for each
;defined segment in the program).
;ONLY active on command line!
<available option> -> 't'<drive> ;specifies which drive to create
;all temporary files on(-,+ are
; ignored but one must be there).
;ONLY active on command line!
<available option> -> 'p'<drive> ;specifies which drive to create
;the listing file on(-,+ are
; ignored but one must be there).
;ONLY active on command line!
<drive> -> <drive name>':' ;e.g. a: b: c: d:
;MS-DOS
<drive name> -> 'a' ;drive a --usually a floppy disk
<drive name> -> 'b' ;drive b --usually a second floppy disk
<drive name> -> 'c' ;drive c --usually a hard disk, but may
be a ram disk.
<drive name> -> 'd' ;drive d --usually a ram disk, but may
be a hard disk.
** The default options are:
Intel: -a1 -m1 -w132 -h66 +l +s +o
Motorola: -a2 -m1 -w132 -h66 +l +s +o
2. .org <integer expression> ;sets the assembler location counter
;to the value of expression.
;The expression MUST be evaluatable
;on the first pass. NO FORWARD
;REFERENCES!
3. .equ <identifier> ',' <integer expression>
;gives identifier the value of the
;integer expression.
;<identifier> canNOT be redefined!
;also forward references are allowed
;as long as they are resolved by the
;second pass.
4. .set <identifier> ',' <integer expression>
;gives identifier the value of the
;integer expression.
;<identifier> CAN be redefined later
; in the program!
;also forward references are allowed
;as long as they are resolved by the
;second pass.
5. .rs <integer expression> ;increments the location counter
;by the value of <integer expresson>
;effectively reserving that many bytes
;of memory.
6. .db <expression-string list>
<expression-string list> -> <expression>','<expression-string list>
<expression-string list> -> <string>','<expression-string list>
<expression-string list> -> <expression>
<expression-string list> -> <string>
;creates a byte in the machine code
;for each <expression> in the list
;and a byte for each ascii character
;in the a string.
7. .dw <expression list>
<expression list> -> <expression>','<expression list>
<expression list> -> <expression>
;creates a word(16 bit) in the machine code
;for each <expression> in the list.
;MOST significant byte is stored at LOWER
;address.
8. .drw <expression list>
<expression list> -> <expression>','<expression list>
<expression list> -> <expression>
;creates a word(16 bit) in the machine code
;for each <expression> in the list.
;LEAST significant byte is stored at LOWER
;address.
9. .eject ;causes a form-feed character to be
;inserted in listing.(new listing page)
10. .page ;increments location counter to next
;256 byte page boundary.
11. .end <integer expression> ;signals the end of the source program.
;the optional expression, if supplied,
;specifies the start address of the
;program, and is included in the
;Hex object module output
;of the active segment when the .end
;was encountered.
12. .opdef <identifier>,<identifier>
;assigns the current definition of
;the second <identifier> to the
;first <identifier>.
;useful for renaming opcodes and
;pseudo-ops.
13. .segment <identifier> ',' <integer expression>
;defines a memory segment name.
;used to separate memory allocation
;and optionally generate seperate
;object files.(see 'o' assembly
;directive to activate).
;(used to seperate RAM, ROM, or
; ROMS)
;the optional <integer expression> is
;added to the location counter to
;offset the load address supplied
;in the object module. (does not
;affect listings addresses!)
;
;note: .code is the predefined default
;segment and cannot be redefined.
14. <segment name> ;selects the segment <segment name>
;as the current memory segment.
;The location old segment location counter
;is saved and the previous value of the
;newly selected segments location counter
;is used(0 if not previously used).
15. .null ;directs the assembler to treat this
;statement as a comment. Useful to
;nullify opcodes when used in conjunction
;with the .opdef pseudo-op.
Appendix A ASCII character set
dec oct hex char dec oct hex char dec oct hex char dec oct hex char
0 000 00 ^@ null 32 040 20 sp 64 100 40 @ 96 140 60 `
1 001 01 ^A soh 33 041 21 ! 65 101 41 A 97 141 61 a
2 002 02 ^B stx 34 042 22 " 66 102 42 B 98 142 62 b
3 003 03 ^C etx 35 043 23 # 67 103 43 C 99 143 63 c
4 004 04 ^D eot 36 044 24 $ 68 104 44 D 100 144 64 d
5 005 05 ^E enq 37 045 25 % 69 105 45 E 101 145 65 e
6 006 06 ^F ack 38 046 26 & 70 106 46 F 102 146 66 f
7 007 07 ^G bel 39 047 27 ' 71 107 47 G 103 147 67 g
8 010 08 ^H bs 40 050 28 ( 72 110 48 H 104 150 68 h
9 011 09 ^I ht 41 051 29 ) 73 111 49 I 105 151 69 i
10 012 0A ^J lf 42 052 2A * 74 112 4A J 106 152 6A j
11 013 0B ^K vt 43 053 2B + 75 113 4B K 107 153 6B k
12 014 0C ^L ff 44 054 2C , 76 114 4C L 108 154 6C l
13 015 0D ^M cr 45 055 2D - 77 115 4D M 109 155 6D m
14 016 0E ^N so 46 056 2E . 78 116 4E N 110 156 6E n
15 017 0F ^O si 47 057 2F / 79 117 4F O 111 157 6F o
16 020 10 ^P dle 48 060 30 0 80 120 50 P 112 160 70 p
17 021 11 ^Q dc1 49 061 31 1 81 121 51 Q 113 161 71 q
18 022 12 ^R dc2 50 062 32 2 82 122 52 R 114 162 72 r
19 023 13 ^S dc3 51 063 33 3 83 123 53 S 115 163 73 s
20 024 14 ^T dc4 52 064 34 4 84 124 54 T 116 164 74 t
21 025 15 ^U nak 53 065 35 5 85 125 55 U 117 165 75 u
22 026 16 ^V syn 54 066 36 6 86 126 56 V 118 166 76 v
23 027 17 ^W etb 55 067 37 7 87 127 57 W 119 167 77 w
24 030 18 ^X can 56 070 38 8 88 130 58 X 120 170 78 x
25 031 19 ^Y em 57 071 39 9 89 131 59 Y 121 171 79 y
26 032 1A ^Z sub 58 072 3A : 90 132 5A Z 122 172 7A z
27 033 1B ^[ esc 59 073 3B ; 91 133 5B [ 123 173 7B {
28 034 1C ^\ fs 60 074 3C < 92 134 5C \ 124 174 7C |
29 035 1D ^] gs 61 075 3D = 93 135 5D ] 125 175 7D }
30 036 1E ^^ rs 62 076 3E > 94 136 5E ^ 126 176 7E ~
31 037 1F ^_ us 63 077 3F ? 95 137 5F _ 127 176 7F del
^ denotes control key simultaneous with character key.
Appendix B Copyright Information:
Disclaimer:
PseudoSam software is distributed as is, with no guarantee that it
will work correctly in all situations. In no event will the
Author be liable for any damages, including lost profits,
lost savings or other incidental or consequential damages
arising out of the use of or inability to use these
programs, even if the Author has been advised of the
possibility of such damages, or for any claim by any other
party.
Copyright Information:
The entire PseudoSam distribution package, consisting of
the main program, documentation files, and various data and
utility files, is copyright (c) 1986, by PseudoCode.
The author reserves the exclusive right to distribute this
package, or any part thereof, for profit.
The name "PseudoSam (tm)", applied to an assembler
program, is a trade mark of the PseudoCode company.
PseudoSam version 1.x.xx and various subsidiary files may be
copied freely by individuals for non-commercial purposes. It
is expected that those who find the package useful will
purchase the commercial version.
ONLY UNMODIFIED VERSIONS DISPLAYING THE AUTHORS COPYRIGHT
MAY BE COPIED.
User groups and clubs are authorized to distribute PseudoSam
software under the following conditions:
1. No charge is made for the software or documentation. A
nominal distribution fee may be charged, provided that
it is no more than $10 total.
3. The program and documentation are not modified in ANY
way, and are distributed together.